package com.bjsxt.service.impl;

import com.bjsxt.dao.UserLoginDao;
import com.bjsxt.dao.impl.UserLoginDaoImpl;
import com.bjsxt.exception.UserNotFoundException;
import com.bjsxt.pojo.Users;
import com.bjsxt.service.UserLoginService;
/*业务层*/
/*用户登录实现*/
public class UserLoginServiceImpl implements UserLoginService {
    //用户登录
    @Override
    public Users userLogin(String username, String userpwd) {
        //接口 实例化接口实现类
        UserLoginDao userLoginDao = new UserLoginDaoImpl();

        Users users =  userLoginDao.selectUserByUserNameAndUserpwd(username,userpwd);

        //用户没有查到是空
        if(users == null){
            //自定义异常  解决层与层之间的耦合问题
            throw new UserNotFoundException("用户名或密码有误");
        }
        return users;
    }
}
